package cn.kgc.tangcco.scanner;

import java.util.Random;
import java.util.Scanner;

/**
 * @author 李昊哲
 * @Description
 * @date 2020/8/14 上午11:41
 */
public class Game {
    public static int count;

    public static void main(String[] args) {
        Random random = new Random();
        int i = random.nextInt(100);
        Scanner scanner = new Scanner(System.in);
        System.out.println("~~~~~~~~~~猜数字小游戏~~~~~~~~~~");
        System.out.println("请输入数字猜一个0到100之间且不包含100的整数");
        guess(i, scanner);
    }

    public static void guess(int i, Scanner scanner) {
        count++;
        System.out.print("请输入>>>");
        int nextInt = scanner.nextInt();
        if (i == nextInt) {
            if (count <= 3) {
                System.out.println("真厉害" + count + "次就猜中了数字" + i);
            } else if (count > 3 && count <= 5){
                System.out.println("真优秀" + count + "次就猜中了数字" + i);
            }else if (count > 5 && count < 10){
                System.out.println("恭喜" + count + "次就猜中了数字" + i);
            }

        } else {
            if (count >= 10) {
                System.out.println("笨蛋别玩儿了");
                return;
            }
            if (i < nextInt) {
                System.out.println("很可惜，您猜大了,继续努力");
            } else {
                System.out.println("很可惜，您猜小了,继续努力");
            }
            // 递归
            guess(i, scanner);
        }
    }
}
